<?php
/**
 * Nweb Editor
 *
 * This script is protected by copyright. Its use, copying, modification
 * and distribution without written consent of the author is prohibited.
 *
 * @category    source
 * @package     pl.nweb.editor.view
 * @subpackage  helper
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2012 Krzysztof Kardasz
 * @license     http://www.gnu.org/licenses/lgpl-3.0.txt  GNU Lesser General Public
 * @version     1.0 $Id$
 * @link        https://nweb-editor.googlecode.com
 * @link        http://editor.nweb.pl
 */

/**
 * Pomocnik widoku, plik medium
 *
 * @category    source
 * @package     pl.nweb.editor.view
 * @subpackage  helper
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2012 Krzysztof Kardasz
 * @version     1.0 $Id$
 */
class Zend_View_Helper_MediaFile extends Zend_View_Helper_Abstract
{
    /**
     * Zwraca url do pliku
     *
     * @param  integer $id id pliku
     * @param  string $language język
     * @param  string $extension rozszerzenie pliku
     * @return string
     */
    public function mediaFile ($id, $language, $extension)
    {
        $hash      = sha1($id);
        $extension = '.' . ltrim($extension, '.');
        $dir       = $this->view->baseUrl('media/data/' . $language . '/' . substr($hash, 0, 3));

        return implode('/', array($dir, ($hash . $extension)));
    }
}
